package com.yang.design.behavior.observe;

public class Client {
    public static void main(String[] args) {

        //定义观察者
        Observer observer1 = new ConcreteObserver("观察者1");
        Observer observer2 = new ConcreteObserver("观察者2");

        //添加观察者
        Subject subject = new ConcreteSubject();
        subject.add(observer1);
        subject.add(observer2);

        //观察者修改,需要强转一下，要不然访问不到setState方法
        ((ConcreteSubject)subject).setState(2);
        System.out.println("========");
        ((ConcreteSubject)subject).setState(3);
    }
}
